var Namespace = 
function ()
{
	function create( path, source )
	{
		if( typeof path == "object" ) return path;
		return _create( path.split( "." ), _getValidSource( source ) );
	}

	function addToNamespace( path, object, source )
	{
		var pieces 	= path.split( "." );
		var prop 	= pieces.pop();
		return _add( _create( pieces, source ), prop, object );
	}
	
	function import( path, target )
	{
		target = _getValidSource( target );
		var pieces 	= path.split( "." );
		var prop	= pieces.pop();
		path 		= _create( pieces, target );
		_add( target, prop, path[ prop ] );
		return null;
	}
	
	function _add( orig, name, value )
	{
		orig[ name ] = value;
		return orig;
	}

	function _create( pieces, orig )
	{
		orig = _getValidSource( orig );
		for( var i = 0; i < pieces.length; i++ )
		{
			var piece = pieces[ i ];
			if( !orig[ piece ] ) orig[ piece ] = {};
			orig = orig[ piece ];
		}
		return orig;
	}
	
	function _getValidSource( source )
	{
		if( !source || typeof source != "object" )
		{
			return window;
		}
		return source;
	}
	
	return {
		"create": 			create,
		"addToNamespace":	addToNamespace,
		"import":			import
	}
}();
